package br.ufrj.pesc;

import java.net.MalformedURLException;
import java.util.ArrayList;

import br.ufrj.pesc.cassandra.SearchCassandraHandler;
import br.ufrj.pesc.consultas.SequenciaDeConsultasFACTORY;
import br.ufrj.pesc.solr.SearchSolrHandler;

public class Benchmark {

	/**
	 * @param args
	 * @throws MalformedURLException 
	 */
	public static void main(String[] args) throws MalformedURLException {
		
		ArrayList<ThreadDeConsulta> listaThreads = new ArrayList<ThreadDeConsulta>();
		for(int i=0;i<3;i++){
			listaThreads.add(new ThreadDeConsulta());
		}
		for (ThreadDeConsulta t: listaThreads){
			
			t.consultas= SequenciaDeConsultasFACTORY.getSequencia(t.id);
			t.banco= new SearchSolrHandler();
		}
		int i=-1;
		for (ThreadDeConsulta t: listaThreads){
			t.id=++i;
			t.start();
		}
		
		// TODO Auto-generated method stub
		System.out.println("iniciou threads");
		for (ThreadDeConsulta t: listaThreads){
			try {
				t.join();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		System.out.println("acabou join");
		for (ThreadDeConsulta t: listaThreads){
			System.out.println(t.tempoConsultas());
		}
		System.out.println("terminou");
		

	}

}
